import { reqcatelist } from "../../request/api"
const state = {
    //初始值
    list: []
}

const getters = {
    //导出给组件
    list(state) {
        return state.list
    }
}

const mutations = {
    //修改list
    changeList(state, list) {
        state.list = list;
    }
}

const actions = {
    //请求
    reqList(context) {
        reqcatelist({ istree: true }).then(res => {
            if (res.data.code == 200) {
                //修改list
                let list = res.data.list ? res.data.list : [];
                context.commit("changeList", list)

            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}